<?php

namespace Biz\service\BrandRights;

use Biz\model\brandRights\BrandLevelRightsConfig as mBrandLevelRightsConfig;
use Biz\model\brandRights\BrandLevelRightsLog as mBrandLevelRightsLog;
use Biz\model\brandRights\BrandRightsSource as mBrandRightsSource;

class BrandLevelRightsLogService
{
    /**
     * @desc 查询品牌是否首次升级到该等级
     * @param int $brandId
     * @param int $level
     * @return bool
     */
    public static function isFirst($brandId, $level)
    {
        $where['brand_id'] = $brandId;
        $where['level'] = $level;
        $bRet = mBrandLevelRightsLog::dataHas($where);
        return !$bRet;
    }

    /**
     * 获取品牌某个等级的权益记录
     * @param int $brandId
     * @param int $level
     * @return array
     */
    public static function getBrandOneLevelRights($brandId, $level)
    {
        $where['brand_id'] = $brandId;
        $where['level'] = $level;
        $result = mBrandLevelRightsLog::dataSelect($where);
        $logs = [];
        if ($result && is_array($result)) {
            $logs = $result;
        }
        return $logs;
    }

}